import i18n from '@/i18n'
import { SwaggerFactory } from '@libs/lhy-common'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { MetaOpenApiModule } from './gateway/meta-open-api/meta-open-api.module'
import { MetaPlatformApiModule } from './gateway/meta-platform-api/meta-platform-api.module'
import { SystemModule } from './gateway/system/system.module'

SwaggerFactory.registry(app => {
  SwaggerFactory.load(
    app,
    'swagger/meta/web',
    'swagger/meta_web.json',
    SwaggerModule.createDocument(
      app,
      new DocumentBuilder()
        .setTitle(i18n.t('app-meta.src.swagger.1215073-0'))
        .setDescription(i18n.t('app-meta.src.swagger.1215073-0'))
        .setVersion('v1.0')
        .build(),
      {
        include: [SystemModule],
        deepScanRoutes: true,
        operationIdFactory: (controllerKey: string, methodKey: string) => methodKey,
      }
    )
  )

  SwaggerFactory.load(
    app,
    'swagger/meta/server',
    'swagger/meta_server.json',
    SwaggerModule.createDocument(
      app,
      new DocumentBuilder()
        .setTitle(i18n.t('app-meta.src.swagger.1215073-1'))
        .setDescription(i18n.t('app-meta.src.swagger.1215073-1'))
        .setVersion('v1.0')
        .build(),
      {
        include: [MetaOpenApiModule, MetaPlatformApiModule],
        deepScanRoutes: true,
        operationIdFactory: (controllerKey: string, methodKey: string) => methodKey,
      }
    )
  )
})
